import request from '@/utils/request'

/**
 * 获取配送员列表
 * @returns {AxiosPromise}
 */
export function getDeliveryClerkList(params) {
  return request({
    url: '/api/Deliveries',
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 获取指定配送员
 * @param id
 */
export function getDisTriClerkApi(id) {
  return request({
    url: `api/Deliveries/${id}`,
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
  });
};

/**
 * 更新部分字段
 * @param data
 * @returns {AxiosPromise}
 */
export function patchDeliveryClerk(data, id) {
  return request({
    url: `/api/Deliveries/${id}`,
    method: 'PATCH',
    data
  });
};

/**
 * 修改配送员
 * @param data
 * @param id
 * @returns {AxiosPromise}
 */
export function putDeliveryClerk(data, id) {
  return request({
    url: `/api/Deliveries/${id}`,
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 删除配送员信息
 * @param id 唯一值
 * @returns {AxiosPromise}
 */
export function deleteDeliveryClerk(id) {
  console.log(id);
  return request({
    url: `/api/Deliveries/${id}`,
    method: 'DELETE'
  });
};

/**
 * 添加配送员信息
 * @param data 配送员对象
 * @returns {AxiosPromise}
 */
export function postDeliveryClerk(data) {
  return request({
    url: '/api/Deliveries',
    method: 'POST',
    data
  })
}

/**
 * 获取物流公司
 * @returns {AxiosPromise}
 */
export function getLogisticsList(params) {
  return request({
    url: '/api/Expresses',
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 获取指定物流公司
 * @param data
 * @returns {AxiosPromise}
 */
export function getLogisticsInfo(id) {
  return request({
    url: `/api/Expresses/${id}`,
    method: 'GET',
    headers: {
      Accept: 'application/json'
    }
  });
};

/**
 * 更新物流公司部分字段
 * @param data
 * @param id
 * @returns {AxiosPromise}
 */
export function patchLogisticsField(data, id) {
  return request({
    url: `/api/Expresses/${id}`,
    method: 'PATCH',
    headers: {
      isToken: true
    },
    data
  });
};

/**
 * 删除与批量删除
 * @param id
 * @returns {AxiosPromise}
 */
export function delExpressApi(ids) {
  return request({
    url: `/api/Expresses/${ ids }`,
    method: 'DELETE'
  });
};

/**
 * 编辑物流公司页面
 * @param data
 * @returns {AxiosPromise}
 */
export function putLogistics(data, id) {
  return request({
    url: `/api/Expresses/${id}`,
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 新增物流公司信息
 * @param data
 * @returns {AxiosPromise}
 */
export function postLogisticsInfo(data) {
  return request({
    url: '/api/Expresses',
    method: 'POST',
    data
  })
}

/**
 * 获取小程序配置
 * @returns {AxiosPromise}
 * @constructor
 */
export function GETWechatApplet() {
  return request({
    url: '/api/System/WxOpenConfig',
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign({}, { isGet: true })
  });
};

/**
 * 修改小程序配置
 * @param data 数据
 * @returns {AxiosPromise}
 * @constructor
 */
export function PUTWechatApplet(data) {
  return request({
    url: '/api/System/WxOpenConfig',
    method: 'PUT',
    data
  });
};

/**
 * 获取公众号配置
 * @returns {AxiosPromise}
 */
export function getOfficialListApi() {
  return request({
    url: '/api/System/WxMPConfig',
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign({}, { isGet: true })
  });
};

/**
 * 修改公众号配置
 * @param data 数据
 * @returns {AxiosPromise}
 * @constructor
 */
export function PUTOfficialListApi(data) {
  return request({
    url: '/api/System/WxMPConfig',
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 获取微信支付配置
 * @returns {AxiosPromise}
 */
export function getWxPayConfigApi() {
  return request({
    url: '/api/System/WxPayConfig',
    method: 'GET',
    params: Object.assign({}, { isGet: true })
  })
}

/**
 * 修改微信支付配置
 * @param data 数据
 * @returns {AxiosPromise}
 * @constructor
 */
export function PUTWxPayConfigApi(data) {
  return request({
    url: '/api/System/WxPayConfig',
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 获取所有分类
 * @returns {AxiosPromise}
 * @constructor
 */
export function GETAttachmentCatesListAPi(id) {
  return request({
    url: `/api/AttachmentCates/${id}`,
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    // params: Object.assign({}, { isGet: true })
  });
};

/**
 * 获取所有附件
 * @returns {AxiosPromise}
 * @constructor
 */
export function GETAttachmentsListAPi(id,params) {
  return request({
    url: `/api/Attachments/${id}`,
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 添加附件分类
 * @param data
 * @returns {AxiosPromise}
 * @constructor
 */
export function POSTAttachmentCatesApi(id,data) {
  return request({
    url: `/api/AttachmentCates/${id}`,
    method: 'POST',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 更新附件分类
 * @param id  ID
 * @param data 数据
 * @returns {AxiosPromise}
 * @constructor
 */
export function PUTAttachmentCatesApi(selectedId,id, data) {
  return request({
    url: `/api/AttachmentCates/${selectedId}/${id}`,
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 删除附件分类
 * @param id  ID
 * @returns {AxiosPromise}
 * @constructor
 */
export function DELAttachmentCatesApi(selectedId,id) {
  return request({
    url: `/api/AttachmentCates/${selectedId}/${id}`,
    method: 'DELETE',
  })
}

/**
 * 删除附件
 * @param id
 * @returns {AxiosPromise}
 * @constructor
 */
export function DELAttachmentsApi(selectedId,id) {
  return request({
    url: `/api/Attachments/${selectedId}/${id}`,
    method: 'DELETE',
    headers: {
      isToken: true
    }
  })
}

/**
 * 修改附件
 * @param id ID
 * @param data 数据
 * @returns {AxiosPromise}
 * @constructor
 */
export function PATCHAttachmentsApi(selectedId,cateId, data) {
  return request({
    url: `/api/Attachments/${selectedId}/Multiple/${cateId}`,
    method: 'PATCH',
    data
  })
}

/**
 * 获取退货设置
 * @returns {AxiosPromise}
 */
export function getRefundListApi() {
  return request({
    url: `api/system/refundConfig`,
    method: 'GET',
    params: Object.assign({}, { isGet: true })
  });
};

/**
 * 修改退货设置
 * @returns {AxiosPromise}
 */
export function putRefundContentApi(data) {
  return request({
    url: `api/system/refundConfig`,
    method: 'PUT',
    data: data
  })
};

/**
 * 商城设置
 * @returns {AxiosPromise}
 */
export function getSysMallConfigApi() {
  return request({
    url: `api/system/mallConfig`,
    method: 'GET',
    params: Object.assign({}, { isGet: true })
  });
};

/**
 * 修改商城设置
 * @param data
 * @returns {AxiosPromise}
 */
export function putSysMallConfigApi(data) {
  return request({
    url: `api/system/mallConfig`,
    method: 'PUT',
    data: data
  })
};

/**
 * 站点设置
 * @returns {AxiosPromise}
 */
export function getSysSiteConfigApi() {
  return request({
    url: `api/system/config`,
    method: 'GET',
    params: Object.assign({}, { isGet: true })
  });
};

/**
 * 修改站点设置
 * @param data
 * @returns {AxiosPromise}
 */
export function putSysSiteConfigApi(data) {
  return request({
    url: `api/system/config`,
    method: 'PUT',
    data: data
  })
};

/**
 * 获取所有热门关键词
 * @returns {AxiosPromise}
 */
export function getHotKeywordsListApi(params) {
  return request({
    url: `api/HotKeywords`,
    method: 'GET',
    headers: {
      Accept: 'application/json'
    },
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 获取指定热门关键词
 * @param guid
 * @returns {AxiosPromise}
 */
export function getQueryEditApi(guid) {
  return request({
    url: `api/HotKeywords/${guid}`,
    method: 'GET'
  });
}

/**
 * 更新热门关键词
 * @param guid
 * @param data
 * @returns {AxiosPromise}
 */
export function putHotKeywordApi(guid, data) {
  return request({
    url: `api/HotKeywords/${guid}`,
    method: 'PUT',
    data: data
  });
};

/**
 * 添加热门关键词
 * @param data
 * @returns {AxiosPromise}
 */
export function postHotKeywordApi(data) {
  return request({
    url: `api/HotKeywords`,
    method: 'POST',
    data: data
  });
};

/**
 * 删除热门关键词
 * @param id
 * @returns {AxiosPromise}
 */
export function delHotKeywordsApi(id) {
  return request({
    url: `/api/HotKeywords/${id}`,
    method: 'DELETE'
  })
};

/**
 * 批量删除热门关键词
 * @param ids
 * @returns {AxiosPromise}
 */
export function batchDELHotKeyApi(ids) {
  return request({
    url: `/api/HotKeywords/(${ids})`,
    method: 'DELETE'
  });
};
